<?php if (!defined('SHUIPF_VERSION')) exit(); ?>
<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<title>添加新商品 - 系统后台 - {$Config.sitename} - by RUI</title>
	<Admintemplate file="Admin/Common/Cssjs"/>
	<style type="text/css">
.col-auto {
	overflow: hidden;
	_zoom: 1;
	_float: left;
	border: 1px solid #c2d1d8;
}
.col-right {
	float: right;
	width: 210px;
	overflow: hidden;
	margin-left: 6px;
	border: 1px solid #c2d1d8;
}

body fieldset {
	border: 1px solid #D8D8D8;
	padding: 10px;
	background-color: #FFF;
}
body fieldset legend {
    background-color: #F9F9F9;
    border: 1px solid #D8D8D8;
    font-weight: 700;
    padding: 3px 8px;
}
.list-dot{ padding-bottom:10px}
.list-dot li,.list-dot-othors li{padding:5px 0; border-bottom:1px dotted #c6dde0; font-family:"宋体"; color:#bbb; position:relative;_height:22px}
.list-dot li span,.list-dot-othors li span{color:#004499}
.list-dot li a.close span,.list-dot-othors li a.close span{display:none}
.list-dot li a.close,.list-dot-othors li a.close{ background: url("{$config_siteurl}statics/images/cross.png") no-repeat left 3px; display:block; width:16px; height:16px;position: absolute;outline:none;right:5px; bottom:5px}
.list-dot li a.close:hover,.list-dot-othors li a.close:hover{background-position: left -46px}
.list-dot-othors li{float:left;width:24%;overflow:hidden;}

</style>
</head>
<body class="J_scroll_fixed">
	<div class="wrap J_check_wrap">
		<!-- <div class="nav">
			<ul class="cc">
				<li class="current">
					<a href="{:U('Content/classlist', array('catid'=>$catid)  )}">{$category.catname}列表</a>
				</li>
			</ul>
		</div> -->
		<div class="h_a">温馨提示</div>
		<div class="prompt_text">
			<p>请不要发布违反法律不允许的内容！</p>
		</div>
		<form name="myform" id="myform" action="{:U("Buy/Buy/addGoodsSave")}" method="post" class="J_ajaxForms" enctype="multipart/form-data">
			<div class="col-right">
				<div class="table_full">
					<table width="100%">
						<tr>
          					<td><b>封面图</b></td>
        				</tr>
						<tr>
          <td><div style="text-align: center;"><input type="hidden" name="picindex" id="picindex" value="">
			<a href="javascript:void(0);" onclick="flashupload('picindex_images', '附件上传','picindex',thumb_images,'1,jpg|jpeg|gif|png|bmp,1,,,1','content','1','{$authkey}');return false;">
			<img src="{$config_siteurl}statics/images/icon/upload-pic.png" id="picindex_preview" width="135" height="113" style="cursor:hand"></a>
            <input type="button" class="btn" onclick="$('#picindex_preview').attr('src','{$config_siteurl}statics/images/icon/upload-pic.png');$('#picindex').val('');return false;" value="取消图片">
            </div></td>
        </tr>
        <tr>
                    <td><b>缩略图</b></td>
                </tr>
            <tr>
          <td><div style="text-align: center;"><input type="hidden" name="pic" id="pic" value="">
      <a href="javascript:void(0);" onclick="flashupload('pic_images', '附件上传','pic',thumb_images,'1,jpg|jpeg|gif|png|bmp,1,,,1','content','1','{$authkey}');return false;">
      <img src="{$config_siteurl}statics/images/icon/upload-pic.png" id="pic_preview" width="135" height="113" style="cursor:hand"></a>
            <input type="button" class="btn" onclick="$('#pic_preview').attr('src','{$config_siteurl}statics/images/icon/upload-pic.png');$('#pic').val('');return false;" value="取消图片">
            </div></td>
        </tr>
        <tr>
                    <td><b>推荐图</b></td>
                </tr>
            <tr>
          <td><div style="text-align: center;"><input type="hidden" name="picpos" id="picpos" value="">
      <a href="javascript:void(0);" onclick="flashupload('picpos_images', '附件上传','picpos',thumb_images,'1,jpg|jpeg|gif|png|bmp,1,,,1','content','1','{$authkey}');return false;">
      <img src="{$config_siteurl}statics/images/icon/upload-pic.png" id="picpos_preview" width="135" height="113" style="cursor:hand"></a>
            <input type="button" class="btn" onclick="$('#picpos_preview').attr('src','{$config_siteurl}statics/images/icon/upload-pic.png');$('#picpos').val('');return false;" value="取消图片">
            </div></td>
        </tr>
					</table>
				</div>
			</div>
			<div class="col-auto">
				<div class="h_a">商品内容</div>
				<div class="table_full">
					<table width="100%">
						<tbody>
							<tr>
              <th width="80">
                商品分类
               </th>
              <td><span class="must_red">*</span>
              	<select name="category" id="category">
              		<option value="">选择栏目</option>
              		<option value="1">新房</option>
              		<option value="2">二手房</option>
              	</select>
              </td>
            </tr>
							<tr>
              <th width="80">
                商品标题 
               </th>
              <td><span class="must_red">*</span><input type="text" style="width:400px;" name="title" id="title" value="" class="input input_hd J_title_color" placeholder="请输入标题" onkeyup="strlen_verify(this, 'title_len', 160)"/>
                还可输入<b><span id="title_len">160</span></b> 个字符 </td>
            </tr>
            <tr>
              <th width="80">
                现价
               </th>
              <td><span class="must_red">*</span><input type="text" name="nowprice" id="nowprice" value="" style="width:180px" class="input" placeholder="请输入现价">例：5000.00</td>
            </tr>
            <tr>
              <th width="80">
                原价
               </th>
              <td><span class="must_red">*</span><input type="text" name="oldprice" id="oldprice" value="" style="width:180px" class="input" placeholder="请输入原价">例：10000.00</td>
            </tr>
            <tr>
              <th width="80">
                开始时间 
               </th>
              <td><span class="must_red">*</span><input type="text" name="starttime" id="starttime" value="" size="10" class="input length_3 J_date  date" placeholder="请填写活动开始时间"> </td>
            </tr>
            <tr>
              <th width="80">
                结束时间 
               </th>
              <td><span class="must_red">*</span><input type="text" name="endtime" id="endtime" value="" size="10" class="input length_3 J_date  date" placeholder="请填写活动结束时间"> </td>
            </tr>
            <tr>
              <th width="80">
                关注人数
               </th>
              <td><input type="text" name="attention" id="attention" value="" style="width:180px" class="input" placeholder="请输入关注人数">例：1000</td>
            </tr>
            <tr>
              <th width="80">
                购买基数
               </th>
              <td><input type="text" name="hasbuy" id="hasbuy" value="" style="width:180px" class="input" placeholder="请输入购买人数基数">例：100</td>
            </tr>
            <tr style="">
              <th width="80">
                商品详情
               </th>
              <td style=""><span class="must_red">*</span>
              	<textarea name="content" id="content"></textarea>
                <script type="text/javascript">
                //编辑器路径定义
                var editorURL = GV.DIMAUB;
                </script>
                <script type="text/javascript" src="{$config_siteurl}statics/js/ueditor/editor_config.js"></script>
                <script type="text/javascript" src="{$config_siteurl}statics/js/ueditor/editor_all_min.js"></script>
<script type="text/javascript">
    var editorcontent;
                        UE.commands['attachments'] = {
                            // execCommand : function(cmd){
                            //     flashupload('flashupload', '附件上传','content',ueAttachment,'10,,1,,,0','Contents','1','ea06afe249af026d81b6f1658848c84f');
                            // },
                            queryCommandState : function(){
                                return this.highlight ? -1 :0;
                            }
                        };
                        var editor_config_content = {
                             textarea:'content',
                             toolbars:[['FullScreen', 'Source', '|', 'Undo', 'Redo', '|',
                'Bold', 'Italic', 'Underline', 'StrikeThrough', 'Superscript', 'Subscript', 'RemoveFormat', 'FormatMatch','AutoTypeSet', '|',
                'BlockQuote', '|', 'PastePlain', '|', 'ForeColor', 'BackColor', 'InsertOrderedList', 'InsertUnorderedList','SelectAll', 'ClearDoc', '|', 'CustomStyle',
                'Paragraph', '|','RowSpacingTop', 'RowSpacingBottom','LineHeight', '|','FontFamily', 'FontSize', '|',
                'DirectionalityLtr', 'DirectionalityRtl', '|', '', 'Indent', '|',
                'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyJustify', '|',
                'Link', 'Unlink', 'Anchor', '|', 'ImageNone', 'ImageLeft', 'ImageRight', 'ImageCenter', '|', 'InsertImage', 'Emotion', 'InsertVideo', 'Music','Attachments', 'Map', 'GMap', 'InsertFrame', 'PageBreak', 'insertcode', 'Webapp','Template','Background','|',
                'Horizontal', 'Date', 'Time', 'Spechars', 'WordImage', '|',
                'InsertTable', 'DeleteTable', 'InsertParagraphBeforeTable', 'InsertRow', 'DeleteRow', 'InsertCol', 'DeleteCol', 'MergeCells', 'MergeRight', 'MergeDown', 'SplittoCells', 'SplittoRows', 'SplittoCols', '|',
                 'Print', 'Preview', 'SearchReplace','Help']],
                             minFrameHeight:300
                        };
        
 $(document).ready(function(){
    editorcontent = new baidu.editor.ui.Editor(editor_config_content);
    editorcontent.render( 'content' );
 }); 
</script> 
<style type="text/css">
.content_attr {
	border: 1px solid #CCC;
	padding: 5px 8px;
	background: #FFC;
	margin-top: 6px
}
</style>
</td>
            </tr>
            <tr>
              <th width="80">
                推荐位 
               </th>
              <td>
                <select name="goodspos" id="goodspos">
                  <option value="">选择推荐位</option>
                  <option value="1">首页幻灯片</option>
                  <option value="2">首页文字头条</option>
                  <option value="3">首页站长推荐</option>
                </select>
               </td>
            </tr>
						</tbody>
					</table>
				</div>
			</div>
	<div class="btn_wrap" style="z-index:999;text-align: center;">
		<div class="btn_wrap_pd">
			<input type="hidden" name="ajax" value="1" />
			<button class="btn btn_submit J_ajax_submit_btn"type="submit">提交</button>
			<button class="btn J_ajax_close_btn"type="submit">关闭</button>
		</div>
	</div>
	<!-- <input type="hidden" name="catid" value="{$catid}"/> -->
</form>
</div>
<script type="text/javascript" src="{$config_siteurl}statics/js/common.js?v"></script>
<script type="text/javascript" src="{$config_siteurl}statics/js/content_addtop.js"></script>
<script type="text/javascript"> 
$(function () {
	$(".J_ajax_close_btn").on('click', function (e) {
	    e.preventDefault();
	    Wind.use("artDialog", function () {
	        art.dialog({
	            id: "question",
	            icon: "question",
	            fixed: true,
	            lock: true,
	            background: "#CCCCCC",
	            opacity: 0,
	            content: "您确定需要关闭当前页面嘛？",
	            ok:function(){
					setCookie("refersh_time",1);
					window.close();
					return true;
				}
	        });
	    });
	});
    Wind.use('validate', 'ajaxForm', 'artDialog', function () {
		//javascript
        {$formJavascript}
        jQuery.validator.addMethod('editorcontent',function(){
                //try{editorcontent.sync();}catch(err){};
                return editorcontent.hasContents();
            });
        var form = $('form.J_ajaxForms');
        //ie处理placeholder提交问题
        if ($.browser.msie) {
            form.find('[placeholder]').each(function () {
                var input = $(this);
                if (input.val() == input.attr('placeholder')) {
                    input.val('');
                }
            });
        }
        //表单验证开始
        form.validate({
			//是否在获取焦点时验证
			onfocusout:false,
			//是否在敲击键盘时验证
			onkeyup:false,
			//当鼠标掉级时验证
			onclick: false,
            //验证错误
            showErrors: function (errorMap, errorArr) {
				//errorMap {'name':'错误信息'}
				//errorArr [{'message':'错误信息',element:({})}]
				try{
					$(errorArr[0].element).focus();
					art.dialog({
						id:'error',
						icon: 'error',
						lock: true,
						fixed: true,
						background:"#CCCCCC",
						opacity:0,
						content: errorArr[0].message,
						cancelVal: '确定',
						cancel: function(){
							$(errorArr[0].element).focus();
						}
					});
				}catch(err){
				}
            },
            //验证规则
            rules: {
            	'category':{required:1},
            	'title':{required:1},
            	'nowprice':{required:1},
            	'oldprice':{required:1},
            	'starttime':{required:1},
            	'endtime':{required:1},
            	'content':{editorcontent:true}
            },
            //验证未通过提示消息
            messages: {
            	'category':{required:'请选择商品分类'},
            	'title':{required:'商品标题不能为空'},
            	'nowprice':{required:'请填写现价'},
            	'oldprice':{required:'请填写原价'},
            	'starttime':{required:'活动开始时间不能空'},
            	'endtime':{required:'活动结束时间不能为空那个'},
            	'content':{editorcontent:'请填写商品详情'}
            },
            //给未通过验证的元素加效果,闪烁等
            highlight: false,
            //是否在获取焦点时验证
            onfocusout: false,
            //验证通过，提交表单
            submitHandler: function (forms) {
				var dialog = art.dialog({id: 'loading',fixed: true,lock: true,background: "#CCCCCC",opacity: 0,esc:false,title: false});
                $(forms).ajaxSubmit({
                    url: form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
                    dataType: 'json',
                    beforeSubmit: function (arr, $form, options) {
                        
                    },
                    success: function (data, statusText, xhr, $form) {
						dialog.close();
                        if(data.status){
							setCookie("refersh_time",1);
							//添加成功
							Wind.use("artDialog", function () {
							    art.dialog({
							        id: "succeed",
							        icon: "succeed",
							        fixed: true,
							        lock: true,
							        background: "#CCCCCC",
							        opacity: 0,
							        content: data.info,
									button:[
										{
											name: '继续添加？',
											callback:function(){
												reloadPage(window);
												return true;
											},
											focus: true
										},{
											name: '关闭当前页面',
											callback:function(){
												window.close();
												return true;
											}
										}
									]
							    });
							});
						}else{
							isalert(data.info);
						}
                    }
                });
            }
        });
    });
});
</script>
</body>
</html>